#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@NAME          : test.py
@TIME          : 2024/11/18 19:37:21
@AUTHOR        : chenlip
@VERSION       : 0.0.1
@DESCRIPTION   : 
'''
# --------------------------引用--------------------------
import os, sys, json, shutil
from common.utils import Utils as ut
from common.genfont import *
from common.imgact import ImgAct
from common.pptxact import PPTXAct
# --------------------------引用--------------------------

def testgenpreview():
    '''
        描述
        :Args:
            - var: 描述
        :Return:
    '''
    _objpath = "fonts/chinafont/"
    _objlst = getFontList(_objpath)
    obj_path = _objlst[8]["srcdir"]+_objlst[8]["srcfile"]
    print("test.py: ", obj_path)
    _miniopath = generate_font_preview_minio(obj_path)
    print("test.py: ", _miniopath)

def testimgact():
    '''
        测试图片去水印功能
        :Args:
            - var: 描述
    '''
    _srcpic = r'E:\python\my_note\static\images\redbook\images\1001.png'
    # 裁剪坐标为[y0,y1,x0,x1], 其中(y0, x0)是左上角的坐标, (y1, x1)是右下角的坐标
    # 豆包ai的水印坐标为[1196, 1224, 735, 812]
    _crop_coord = [1196, 1224, 735, 812]
    _logo_color = [[134,134,131], [227,236,193]] # [200,200,200]-[250,250,250]
    ImgAct.single_rm_wm(_srcpic, _crop_coord, _logo_color)

# --------------------------测试PPT相关功能--------------------------
_pptxpath = r'E:\res\tempout\pptx'
def testppt2png():
    _pptxtemp = r'E:\res\templates\内容模板.pptx'
    pptxact = PPTXAct(_pptxpath)
    # 创建一个pptx文件
    _pptxfile = pptxact.createpptx('test.pptx', _pptxtemp)

    # 打印pptx文件的内容
    # pptxact.printpptx(_pptxtemp)

    # 将PPTX文件的每一页转成高清PNG图片
    _pngfiles = pptxact.ppt2png(_pptxtemp)
    print(_pngfiles)

def cls():
    # 清除目录下的所有文件
    shutil.rmtree(_pptxpath)




if __name__ == '__main__':
    testppt2png()
